package com.minhua.jijiehao2.mainframe.home.homeFragment.impl

import com.minhua.jijiehao2.bean.BaseBean
import com.minhua.jijiehao2.bean.ChannelBean
import com.minhua.jijiehao2.bean.HomeBannerBean
import com.minhua.jijiehao2.bean.HomeMenuBean
import com.minhua.jijiehao2.http.*
import com.minhua.jijiehao2.mainframe.home.homeFragment.imp.IHomeModel

class HomeModel : IHomeModel {
    override fun getBannerInfo(map: ParamsMap, callBack: CallBack<HomeBannerBean>) {
        HttpController<HomeBannerBean>().doHttp(
                ApiClient.getInstance().api.getHomeBannerInfo(map.toRequestBody()),
                object : BaseSubscriber<HomeBannerBean>() {
                    override fun dealData(t: BaseBean<HomeBannerBean>) {
                        callBack.onSuccess(t)
                    }
                }, false
        )
    }

    override fun getHotInfo(map: ParamsMap, callBack: CallBack<List<ChannelBean>>) {
        HttpController<List<ChannelBean>>().doHttp(
                ApiClient.getInstance().api.getHomeHotInfo(map.toRequestBody()),
                object : BaseSubscriber<List<ChannelBean>>() {
                    override fun dealData(t: BaseBean<List<ChannelBean>>) {
                        callBack.onSuccess(t)
                    }
                }, false
        )
    }

    override fun getMenuInfo(map: ParamsMap, callBack: CallBack<List<HomeMenuBean>>) {
        HttpController<List<HomeMenuBean>>().doHttp(
                ApiClient.getInstance().api.getListOfHomeMenu(map.toRequestBody()),
                object : BaseSubscriber<List<HomeMenuBean>>() {
                    override fun dealData(t: BaseBean<List<HomeMenuBean>>) {
                        callBack.onSuccess(t)
                    }
                },
                false
        )
    }
}